package Practice04;

import java.util.Arrays;

public class test2 {
    public static void main(String[] args) {

        Circle[] circles = new Circle[5];
        Circle[] circles1 = new Circle[5];

        circles[0] = new Circle(2);
        circles[1] = new Circle(10);
        circles[2] = new Circle(8);
        circles[3] = new Circle(4);
        circles[4] = new Circle(12);

        Arrays.sort(circles);//升序
        circles1 = Arrays.copyOfRange(circles,0,4);

        //(1)
        System.out.println("排序后数组为："+Arrays.toString(circles));

        //(2)
        System.out.println("1~4位复制得到的数组为："+Arrays.toString(circles1));

        //(3)
        if (Arrays.binarySearch(circles,new Circle(9)) < 0){
            System.out.println("未找到radius=9的圆");
        }else {
            System.out.println("找到radius=9的圆");
        }
        if (Arrays.binarySearch(circles,new Circle(10)) < 0){

            System.out.println("未找到radius=10的圆");
        }else {
            System.out.println("找到radius=10的圆");
        }
    }


}
